package lt.mockos.app.client.widget;

import lt.mockos.app.client.cpu.hw.type.ProcessStatus;

import com.google.gwt.dom.client.Style;
import com.google.gwt.dom.client.Style.BorderStyle;
import com.google.gwt.dom.client.Style.Display;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.user.client.ui.SimplePanel;

public class VMStatusIcon extends SimplePanel {

    public VMStatusIcon() {
        setWidth("16px");
        setHeight("16px");
        Style s = getElement().getStyle();
        s.setDisplay(Display.BLOCK);
        s.setBorderStyle(BorderStyle.SOLID);
        s.setBorderColor("#000");
        s.setBorderWidth(1.0, Unit.PX);
        setStatus(ProcessStatus.STOP);
    }

    public void setStatus(ProcessStatus status) {
        Style s = getElement().getStyle();
        switch (status) {
            case RUN:
                s.setBackgroundColor("lightgreen");
                break;
            case READY:
                s.setBackgroundColor("yellow");
                break;
            case BLOCK:
                s.setBackgroundColor("red");
                break;
            case STOP:
                s.setBackgroundColor("lightgrey");
                break;
            default:
                s.setBackgroundColor("lightgrey");
                break;
        }
    }
}
